package com.md.drcs.dicom.dto;

import com.md.drcs.dicom.entity.*;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class StudyDetailDTO extends StudyEntity {

    private PatientEntity patient;
    private ReportEntity report;
    private ReportEntity reportConsul;
    private List<SeriesDTO> serieses;

    private String reportPDF;

    public static class SeriesDTO extends SeriesEntity {

        public static SeriesDTO createFrom(SeriesEntity entity) {
            SeriesDTO dto = new SeriesDTO();
            BeanUtils.copyProperties(entity, dto);
            return dto;
        }

        public static List<SeriesDTO> createFrom(List<SeriesEntity> entities) {
            if (CollectionUtils.isEmpty(entities))
                return new ArrayList<>();
            return entities.stream().map(SeriesDTO::createFrom).collect(Collectors.toList());
        }

        private List<ImageDTO> images;

        public List<ImageDTO> getImages() {
            return images;
        }

        public void setImages(List<ImageDTO> images) {
            this.images = images;
        }
    }

    public static class ImageDTO extends ImageEntity {

        public static ImageDTO createFrom(ImageEntity entity) {
            ImageDTO dto = new ImageDTO();
            BeanUtils.copyProperties(entity, dto);
            return dto;
        }

        public static List<ImageDTO> createFrom(List<ImageEntity> entities) {
            if (CollectionUtils.isEmpty(entities))
                return new ArrayList<>();
            return entities.stream().map(ImageDTO::createFrom).collect(Collectors.toList());
        }

        private String ssrcimgpath;
        private String shttpurlpath;

        public String getSsrcimgpath() {
            return ssrcimgpath;
        }

        public void setSsrcimgpath(String ssrcimgpath) {
            this.ssrcimgpath = ssrcimgpath;
        }

        public String getShttpurlpath() {
            return shttpurlpath;
        }

        public void setShttpurlpath(String shttpurlpath) {
            this.shttpurlpath = shttpurlpath;
        }
    }

    public PatientEntity getPatient() {
        return patient;
    }

    public void setPatient(PatientEntity patient) {
        this.patient = patient;
    }

    public ReportEntity getReport() {
        return report;
    }

    public void setReport(ReportEntity report) {
        this.report = report;
    }

    public List<SeriesDTO> getSerieses() {
        return serieses;
    }

    public void setSerieses(List<SeriesDTO> serieses) {
        this.serieses = serieses;
    }

    public ReportEntity getReportConsul() {
        return reportConsul;
    }

    public void setReportConsul(ReportEntity reportConsul) {
        this.reportConsul = reportConsul;
    }

    public String getReportPDF() {
        return reportPDF;
    }

    public void setReportPDF(String reportPDF) {
        this.reportPDF = reportPDF;
    }
}
